<?php

namespace addons\ymypaypal\controller;

use addons\ymypaypal\services\PayPalService;
use think\addons\Controller;

class Index extends Controller
{
    protected $noNeedLogin = ['*'];
    public function index()
    {
        $this->error("当前插件暂无前台页面");
    }

    public function return(){
        if ($this->request->has('success') && $this->request->get('success') == 'true') {
            // 执行付款
            $PayPalService = new PayPalService();
            $payment = $PayPalService->executePayment($this->request->get('paymentId'));
            dump($payment);exit;
            // TODO: 这里编写支付后的具体业务(如: 跳转到订单详情等...)

        } else {
            // TODO: 这里编写失败后的业务

        }
        exit;
        return $this->view->fetch();
    }
}
